package com.example.user_center.exception;


import com.example.user_center.common.ErrorCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.io.Serial;

/**
 * 自定义异常
 *
 * @author  fld
 */
@Getter
public class BusinessException extends RuntimeException{

    @Serial
    private static final long serialVersionUID = 6519634736823415216L;

    private final int code;

    private final String description;

    // 设置各种构造器
    public BusinessException(int code, String message,String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode,String description) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = description;
    }
}
